home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / reform12.zip / REFORMAT.INC < prev   
Text File  |  1987-05-23  |  3KB  |  71 lines

  1. (*
  2.  REFORMAT.INC
  3.  Inline code for Int25 and Int26 procedures, REFORMAT.PAS
  4.  Author David Kirschbaum (kirsch@braggvax.arpa)
  5.  REFORMAT.PAS author Jos Wennmacker (URC) apr '86.
  6.  
  7.  Jos originally had two .ASM files to produce external procedures
  8.  for absolute disk read and write.
  9.  
  10.  Rather than force the user to go through the assembly routine and keep
  11.  track of a bogus .COM file, I've used INLINE and two different hacks of
  12.  the original .ASM code to create Turbo Pascal inline code.
  13.  
  14.  Since we only use one Registers record variable, AND it's a global one,
  15.  I stripped out passing its address as a parameter and just rely on it
  16.  being in the DS data segment.
  17.  
  18.  Because the code is so redundant (only the interrupt number is different),
  19.  I combined the two procedures, Int25 and Int26, into a new single procedure,
  20.  Int2526.  Now you must pass the interrupt number you desire (25H or 26H).
  21.  I resisted (with difficulty) the temptation for a little self-modifying code,
  22.  rather than listen to the screams on the networks!
  23.  
  24.  This code (plus other changes I made to REFORMAT.PAS to tighten and speed
  25.  it up a little) runs perfectly on an XT clone (Gulfstream Micro Systems
  26.  80286 with a 10 Meg hard disk, 5.25" floppy, PC-DOS 3.1).
  27.  
  28.  Full credit, honors and glory for REFORMAT.PAS to the original author.
  29.  This extension is released to the Public Domain with no constraints.
  30.  
  31.  David Kirschbaum, Toad Hall
  32.  kirsch@braggvax.arpa
  33. *)
  34.  
  35. PROCEDURE Int2526(R : BYTE);
  36.   {Uses global variable Register.  Pass $25 (read) or $26 (write)
  37.    as R for the function you desire.
  38.   }
  39.   BEGIN
  40.     Inline(
  41.    $1E            { push    ds                 ; save what we are about to clobber}
  42.   /$BE/>REGISTERS { mov     si,>Registers      ; load DS:Regs (global) address}
  43.   /$8A/$04        { mov     al,byte ptr[si]    ;Regs.al}
  44.   /$8B/$5C/$02    { mov     bx,[si+2]          ;Regs.bx}
  45.   /$8B/$4C/$04    { mov     cx,[si+4]          ;Regs.cx}
  46.   /$8B/$54/$06    { mov     dx,[si+6]          ;Regs.dx}
  47.   /$56            { push    SI                 ;save Regs addr}
  48.   /$8B/$74/$0E    { mov     si,[si+14]         ;Regs.DS}
  49.   /$8E/$DE        { mov     ds,si              ;DS=Regs.DS}
  50.   /$55            { push    bp                 ; DOS destroys it}
  51.   /$FC            { cld                        ; if you don't, DOS makes a mess!}
  52.   /$80/$BE/>R/$25 { cmp     byte ptr >R[BP],$25 ;doing a read?}
  53.   /$75/$05        { jne     Do26               ; nope}
  54.   /$CD/$25        { int     $25                ; yep, do the read}
  55.   /$E9/$02/$00    { jmp     Done               ; and skip}
  56.                   {Do26:}
  57.   /$CD/$26        { int     $26                ;do the write}
  58.                   {Done:         ;old flags are still on the stack!}
  59.   /$5F            { pop     DI                 ;so save them here a sec}
  60.   /$5D            { pop     BP}
  61.   /$5E            { pop     SI                 ;Regs addr}
  62.   /$1F            { pop     DS                 ;Regs seg}
  63.   /$9C            { pushf                      ;move the new flags...}
  64.   /$8F/$44/$12    { pop     [si+18]            ;into as Reg.Flags}
  65.   /$89/$04        { mov     [si],ax            ;possible errors}
  66.   /$57            { push    DI                 ;old flags..}
  67.   /$9D            { popf                       ;..restored}
  68. );
  69.   {BX,CX,DX should not have changed, so no need to post Regs.}
  70.   END;  {of Int2526}
  71.